//货柜与商品-货柜型号-配置文件
App.util.ns('Admin.Cabinet.Type');
Admin.Cabinet.Type.Conf = {
    columns: [
        {name: '型号名', value: 'name'},
        {name: '格子数', width: '100px',value: 'cells'},
        {name: '规格', width: '120px',value: function(item){
              return item.rows + '行，' + item.cols+'列';  
        }},
        {name: '生产厂家', width: '200px', value: function(item){
            return item.factory ? item.factory.name : '';
        }},
        {name: '状态', width: '80px',value: function(item){
            switch (item.status+'') {
                case '0':
                    return '下线';
                case '1':
                    return '在线';
            }
        }},
        {name: '创建日期', width: '80px', value: function(item){
            return App.util.formator.date(item.created_at);
        }}
    ],
    form: [
        {type: 'hidden', name: 'id'},
        {type: 'input', name: 'name', title: '型号名称', required: true, maxLength: 100, rule: {
            type: 'str',
            range: [1, 200]
        }},
        {type: 'chosen', name: 'factory_id', title: '生产厂家', required: true,
            items: App.models.get('factories-all'), 
            item_key: 'id', 
            item_name: 'name', 
            value_key: 'id',
            rule:{
                type: 'num',
                range: [1, 10]
            }
        },
        [
            {type: 'input', name: 'rows', title: '行数', required: true, 
                rule: {
                    type: 'str',
                    range: [1, 40]
                },
                onChange: function(self){
                    return ;
                    var rowsRaw = self.value();
                    var colsRaw = self.form.formItems['cols'].value();
                    var rows = rowsRaw ? parseInt(rowsRaw) : 0;
                    var cols = colsRaw ? parseInt(colsRaw) : 0;
                    self.form.formItems['cols'].change(rows*cols);
                }
            },
            {type: 'input', name: 'cols', title: '列数', required: true, 
                rule: {
                    type: 'int',
                    range: [1, 100]
                },
                onChange: function(self){
                    return ;
                    var rowsRaw = self.value();
                    var colsRaw = self.form.formItems['cols'].value();
                    var rows = rowsRaw ? parseInt(rowsRaw) : 0;
                    var cols = colsRaw ? parseInt(colsRaw) : 0;
                    self.form.formItems['cols'].change(rows*cols);
                }}   
        ],
        {type: 'input', name: 'cells', title: '格子总数', required: true, 
            rule: {
                type: 'int',
                range: [1, 100]
            }
        },
        {type: 'img', name: 'icon', title: '样图', rule: {
            type: 'str',
            range: [0, 255]
        }},
        {type: 'textarea', name: 'introduction', title: '简介', maxLength: 200,
            rule: {
            type: 'str',
            range: [0, 200]
        }}
    ]
};